﻿
function chartHistoricalData(controllerName, searchSymbol, displayMode) {
    var param = {};
    param.stockSymbol = searchSymbol;
	    $.getJSON(controllerName + "/ChartResults", param, function (data) {
            
	        var renderToString;
	        var titleString = searchSymbol + ' Stock Price';

	        // verify symbol returned valid results
	        if (data.length <= 0) titleString = "Invalid Stock Symbol";

	        // determine display mode for rendering
	        if (displayMode === 'Single') {
	            renderToString = 'chart'
	        }
	        else {
	            renderToString = searchSymbol + 'chart'
	        }

	        // create the chart
	        chart = new Highcharts.StockChart({
	            chart: {
	                    renderTo: renderToString
	            },

	            rangeSelector: {
	                selected: 1
	            },

	            title: {
	                text: titleString
	            },

	            navigator: {
	                outlineColor: 'blue',
	                outlineWidth: 2
	            },

	            series: [{
	                type: 'candlestick',
	                name:searchSymbol + ' Stock Price',
	                turboThreshold: 10000,
	                dataGrouping: {
	                    enabled: false
	                },
	                data: data
	            }]
	        });
	    });
	};